/**
 * toast显示
 * 
 * @param {content} 内容
 * @param {time}    显示时间,单位ms
 */
function toast(content, time) {
  var toast = $('#zq-toast');
  var timeOption;

  if(!time) {
    timeOption = 500;
  }else {
    timeOption = time;
  }

  if(toast.length == 0) {
    var tpl = "<div id='zq-toast' style='position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.6); padding: 12px 22px; font-size: 15px; color: #fff; border-radius: 6px;z-index: 11111'>"
        tpl += "<span>" + content + "</span>"
        tpl += "</div>"
    $('body').append(tpl)

    setTimeout(function() {
      $('#zq-toast').fadeOut(200)
    }, timeOption)
  }else {
    toast.find('span').html(content);
    toast.show();

    setTimeout(function() {
      toast.fadeOut(200)
    }, timeOption)
  }
}

/**
 * 弹窗
 * 
 * @param {title} 头部
 * @param {content}  内容
 */
function ZAlert(title,content,url) {
  var alert = $('#zq-shadow');
  if(alert.length == 0) {
    var tpl = "<div class='shadow' id='zq-shadow'><div id='zq-alert' style='position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 275px; background: #fff; border-radius: 6px;'>";
        tpl+= "<div class='zq-title' style='padding: 15px 0; text-align: center; font-size: 17px; font-weight: 600;'>"+title+"</div>";
        tpl+= "<div class='zq-content' style='padding: 10px 20px 20px;font-size: 15px; border-bottom: 1px solid #e8e8e8; color: #333;text-align: center'>"+content+"</div>";
        tpl+= "<div class='zq-btn' style='padding: 10px; text-align: center; font-size: 17px; color: #e60012;'>确定</div>"
        tpl+= "</div></div>"
    
    $('body').append(tpl);
    alert = $('#zq-shadow');
  }

  alert.fadeIn(200);
  alert.on('click', '.zq-btn', function() {
    alert.fadeOut(200);
    if(url){
      location.href = url;
    }
  })

}

